/**
 * @description 获取问卷数据
 * @author BBQ
 */

import { useSelector } from "react-redux";
import { StateType } from "../store";
import { ComponentStateType } from "../store/componentReducer";

function useGetComponentInfo() {
  const components = useSelector<StateType>(
    (state) => state.components.present
  ) as ComponentStateType;

  // 获取组件列表和选中组件的id
  const {
    componentList = [],
    selectId = "",
    copiedComponent = void 0,
  } = components;
  // 当前选中的组件
  const selectedComponent = componentList.find((c) => c.fe_id == selectId);
  //   console.log(selectedComponent);
  return { componentList, selectId, selectedComponent, copiedComponent };
}

export default useGetComponentInfo;
